import java.util.Scanner;

public class User {
	// 全局变量
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		page();
	}
	
	
	static void page() {
		System.out.println("\t\t欢迎进入用户管理系统");
		System.out.println("\t\t1、登录\t2、注册");
		System.out.println("\t\t3、关闭");
		System.out.println("请选择");
		switch (sc.nextInt()) {
		case 1:
			if (login()) {
				index();
			} else {
				System.out.println("登录失败");
			}

			break;
		case 2:
			if(regester()) {
				System.out.println("注册成功");
				login();
			}else {
				System.out.println("注册失败");
			}
			break;
		case 3:
			System.exit(0);
			break;
		default:
			System.out.println("你选择错误，请重新选择");
			break;

		}
	}
	
	
	static boolean regester() {
		System.out.println("请输入用户名:");
		String userName = sc.next();
		System.out.println("请输入密码:");
		String password = sc.next();
		System.out.println("请输入年龄:");
		int age  = sc.nextInt();
		System.out.println("请输入性别:");
		char sex  = getSex(sc.next());
		return true;
	}

	
	static char getSex(String sexString){
		//unicode码
		char sex = '\u0000';
		//判空处理
		if (null != sexString) {
			sex = sexString.charAt(0);
		}
		return sex;
	}
	static boolean login() {
		System.out.println("请输入用户名:");
		String userName = sc.next();
		System.out.println("请输入密码:");
		String password = sc.next();

		if ("zhangsan".equals(userName) && "123456".equals(password)) {
			System.out.println("登录成功");
			return true;
		}
		System.out.println("用户名或者密码不正确，登录失败");
		return false;
	}

	static void index() {
		System.out.println("1、查询用户\t2、编辑用户");
		System.out.println("3、删除用户\t4、注销");
		System.out.println("请选择");
		switch (sc.nextInt()) {
		case 1:
			System.out.println("查询用户");
			break;
		case 2:
			System.out.println("编辑用户");
			break;
		case 3:
			System.out.println("删除用户");
			break;
		case 4:
			page();
			break;

		default:
			System.out.println("你选择错误，请重新选择");
			break;
		}
	}
}
